home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / CUGUK / GAMES / C014.ZIP / LARN_SRC.ZIP / HELP.C < prev    next >
C/C++ Source or Header  |  1993-11-17  |  3KB  |  128 lines

  1. /* help.c */
  2. #include "header.h"
  3. #include "larndefs.h"
  4.  
  5. /*
  6.  *  help function to display the help info
  7.  *
  8.  *  format of the .larn.help file
  9.  *
  10.  *  1st character of file:  # of pages of help available (ascii digit)
  11.  *  page (23 lines) for the introductory message (not counted in above)
  12.  *  pages of help text (23 lines per page)
  13.  */
  14. extern char helpfile[];
  15. help()
  16.     {
  17.     register int i,j,maxj;
  18. #ifndef VT100
  19. #ifndef MSDOS
  20.     char tmbuf[128];    /* intermediate translation buffer when not a VT100 */
  21. #endif
  22. #endif
  23.  
  24.     /* open the help file and get # pages 
  25.     */
  26.     if ((j=openhelp()) < 0)  
  27.     return;
  28.  
  29.     /* skip over intro message 
  30.     */
  31.     for (i=0; i<23; i++) 
  32.     lgetl();
  33.  
  34.     /* if command mode, skip over the second page (prompt mode help)
  35.     */
  36.     if (!prompt_mode)
  37.     {
  38.     for (i=0; i<23; i++)
  39.         lgetl();
  40.     j--;
  41.     }
  42.  
  43.     for (maxj = j;  j>0; j--)
  44.     {
  45.     clear();
  46.     for (i=0; i<23; i++)
  47. #if (defined(VT100) || defined(MSDOS))
  48.         lprcat(lgetl());    /* print out each line that we read in */
  49. #else
  50.         { 
  51.         tmcapcnv(tmbuf,lgetl());  
  52.         lprcat(tmbuf); 
  53.         } /* intercept \33's */
  54. #endif
  55.     if (j>1)
  56.         {
  57.         lprcat("    ---- Press ");  standout("return");
  58.         lprcat(" to exit, ");       standout("space");
  59.         lprcat(" for more help ---- ");
  60.         i=0; while ((i!=' ') && (i!='\n') && (i!='\33')) i=ttgetch();
  61.         if ((i=='\n') || (i=='\33'))
  62.         {
  63.         lrclose();  
  64.         setscroll();  
  65.         drawscreen();  
  66.         return;
  67.         }
  68.         }
  69.  
  70.     /* For prompt mode, skip over the third page (command mode help)
  71.        This could be done more efficiently, but its not worth the trouble.
  72.     */
  73.     if ((prompt_mode) && (j==maxj))
  74.         {
  75.         for (i=0; i<23; i++)
  76.         lgetl();
  77.         j--;
  78.         }
  79.  
  80.     }
  81.     lrclose();  
  82.     retcont();  
  83.     drawscreen();
  84.     }
  85.  
  86. /*
  87.  *  function to display the welcome message and background
  88.  */
  89. welcome()
  90.     {
  91.     register int i;
  92. #ifndef VT100
  93.     char tmbuf[128];    /* intermediate translation buffer when not a VT100 */
  94. #endif
  95.     if (openhelp() < 0)  return;    /* open the help file */
  96.     clear();
  97.     for(i=0; i<23; i++)
  98. #ifdef VT100
  99.             lprcat(lgetl());    /* print out each line that we read in */
  100. #else
  101.             { tmcapcnv(tmbuf,lgetl());  lprcat(tmbuf); } /* intercept \33's */
  102. #endif
  103.     lrclose();  retcont();  /* press return to continue */
  104.     }
  105.  
  106. /*
  107.  *  function to say press return to continue and reset scroll when done
  108.  */
  109. retcont()
  110.     {
  111.     cursor(1,24); lprcat("Press "); standout("return");
  112.     lprcat(" to continue: ");   while (ttgetch() != '\n');
  113.     setscroll();
  114.     }
  115.  
  116. /*
  117.  *  routine to open the help file and return the first character - '0'
  118.  */
  119. static openhelp()
  120.     {
  121.     if (lopen(helpfile)<0)
  122.         {
  123.         lprintf("Can't open help file \"%s\" ",helpfile);
  124.         lflush(); sleep(4); drawscreen();   setscroll(); return(-1);
  125.         }
  126.     resetscroll();  return(lgetc() - '0');
  127.     }
  128.